<#function dashedToCamel(s)>
  <#return s
  ?replace('(^_+)|(_+$)', '', 'r')
  ?replace('\\_+(\\w)?', ' $1', 'r')
  ?replace('([A-Z])', ' $1', 'r')
  ?capitalize
  ?replace(' ' , '')
  ?uncap_first
  >
</#function>
import storageUtil from '@/utils/StorageUtil'

// local storage Key常量
export const PageVersionKey = 'ps_${table.entityName}-page-version-key'
export const ConditionShowListCkedKey = 'ps_${table.entityName}-condition-column-show-cked-list-key'
export const ColumnShowListCkedKey = 'ps_${table.entityName}-list-column-show-cked-list-key'
export const isDropMenuKey = 'ps_${table.entityName}-list-column-show-isdropmenu-key'
export const ColumnShowListWidthKey = 'ps_${table.entityName}-list-column-width-key'
export const IsExpandedRowCkedKey = 'ps_${table.entityName}-list-isexpanded-row-key'


// 查询条件 type: input/date/date-range/num-range/select/tree/
export const conditionOptions = [
<#list cfg.conditionColumnMapList as column>
  <#if column.tableAliasName=="" || column.tableAliasName=="t1">
  { property: '${column.propertyName}', label: '${column.columnShowName}', width: 200, show: true, type: '${column.columnType}', dataResource: ${column.dataResource}, enumName:'${column.enumName}', remoteUrl: '${column.remoteUrl}' }${column_has_next?string(",","")}
  </#if>
</#list>
]
// 所有列对象
export const theadOptions = [
<#list cfg.columnList as column>
  <#if column.isHidden != 1>
    <#if column.tableAliasName=="" || column.tableAliasName=="t1" >
      <#if column.dataResource==1>
      // 枚举对象， json结构，如: {'id':1, 'name':'无效'}
      { property: '${column.propertyName}.name', label: '${column.columnShowName}', width: storageUtil.getColumnWidthFromStorage('${column.propertyName}.name', ${column.columnWidth}, ColumnShowListWidthKey), show: <#if column.isHidden==2>false<#else>true</#if>, edit: <#if column.canAdd == 1>true<#else>false</#if>, sort: <#if column.propertyName=="id">'custom'<#else>false</#if>, fixed: ${column.fixedStr}, dataResource: ${column.dataResource}, columnType: '${column.columnType}', enumName:'${column.enumName}', remoteUrl: '${column.remoteUrl}'} ${column_has_next?string(",","")}
      <#else>
      { property: '${column.propertyName}', label: '${column.columnShowName}', width: storageUtil.getColumnWidthFromStorage('${column.propertyName}', ${column.columnWidth}, ColumnShowListWidthKey), show: <#if column.isHidden==2>false<#else>true</#if>, edit: <#if column.canAdd == 1>true<#else>false</#if>, sort: <#if column.propertyName=="id">'custom'<#else>false</#if>, fixed: ${column.fixedStr}} ${column_has_next?string(",","")}
      </#if>
    <#else>
      { property: '${column.colClassInstance}.${column.colClassPropertyName}', label: '${column.columnShowName}', width: storageUtil.getColumnWidthFromStorage('${column.colClassInstance}.${column.colClassPropertyName}', ${column.columnWidth}, ColumnShowListWidthKey), show: <#if column.isHidden==2>false<#else>true</#if>, edit: <#if column.canAdd == 1>true<#else>false</#if>, sort: <#if column.propertyName=="id">'custom'<#else>false</#if>, fixed: ${column.fixedStr} } ${column_has_next?string(",","")}
    </#if>
  </#if>
</#list>
]

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

export const pickerOptionsSingleDate = {
  disabledDate(time) {
    return time.getTime() > Date.now()
  },
  shortcuts: [{
    text: '今天',
    onClick(picker) {
      picker.$emit('pick', new Date())
    }
  }, {
    text: '昨天',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      picker.$emit('pick', date)
    }
  }, {
    text: '一周前',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', date)
    }
  }]
}
